package com.cgtong.android.mvp.model;

import com.cgtong.android.http.ApiManager;
import com.cgtong.android.mvp.contract.SignContract;
import com.zhouyou.http.EasyHttp;
import com.zhouyou.http.callback.SimpleCallBack;
import com.zhouyou.http.exception.ApiException;
import com.zhouyou.http.model.ApiResult;

import java.util.List;

/**
 * Created by Tinwai on 2017/10/25.
 */
public class SignModel implements SignContract.Model {
    @Override
    public void sign(final SimpleCallBack<List<ApiResult>> callBack) {
        EasyHttp.post(ApiManager.URL_SIGN).execute(new SimpleCallBack<List<ApiResult>>() {
                    @Override
                    public void onError(ApiException e) {
                        callBack.onError(e);
                    }

                    @Override
                    public void onSuccess(List<ApiResult> result) {
                        callBack.onSuccess(result);
                    }
                });
    }

    @Override
    public void getSignInfo(String date, final SimpleCallBack<List<String>> callBack) {
        EasyHttp.post(ApiManager.URL_GETSIGNINFO).params("date", date)
                .execute(new SimpleCallBack<List<String>>() {
                    @Override
                    public void onError(ApiException e) {
                        callBack.onError(e);
                    }

                    @Override
                    public void onSuccess(List<String> result) {
                        callBack.onSuccess(result);
                    }
                });
    }
}
